/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package concurrent.adder;

/**
 *
 * @author harker777
 */
public class Adder extends ValueReturningRunnableImpl<Integer> {

	private Integer[] data;
	private Integer from;
	private Integer to;

	public Adder(Integer[] data, Integer from, Integer to) {
		this.data = data;
		this.from = from;
		this.to = to;
	}

	@Override
	public void run() {
		Integer result = 0;
		for (int i = from; i <= to; i++) {
			result += data[i];
		}
		setValue(result);
	}
}
